import React from 'react'
import { Modal, message } from 'antd';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { deletedManufacturerRecover} from "../../../../../requests/Manufacturer";


//解构出confirm
const { confirm } = Modal;
export default function recoverManufacturerModal(manufacturerID: number, manufacturerName: string, refresh: () => void) {
    confirm({
        title: `确认恢复 ${manufacturerName} 吗`,
        icon: <ExclamationCircleOutlined />,
        onOk() {
            return deletedManufacturerRecover(manufacturerID).then(msg => {
                if (msg.data.isSuccessful) {
                    message.success('恢复成功')
                    refresh()
                }
                else {
                    message.error('恢复失败')
                }
            }).catch((err) => {
                console.log(err)
            })
        },
        onCancel() { },
    });
}